<template>
	<view class="home_tab">
		<view class="home_tab_title">
			<view class="title_inner">
				<uni-segmented-control :current="current" :values="items.map(v=>v.title)" @clickItem="onClickItem"
					styleType="text" activeColor="#d4237a">
				</uni-segmented-control>
			</view>
			<!-- <view @click="ClickSearch" class="iconfont icon-sousuo"></view> -->
				<navigator url="/pages/search/index" open-type="switchTab" class="iconfont icon-sousuo"></navigator>
		</view>
		<view  class="home_tab_content">
			<view v-if="current === 0">
				<home-recommend></home-recommend>
			</view>
			<view v-if="current === 1">
				<home-category></home-category>
			</view>
			<view v-if="current === 2">
				<home-album></home-album>
			</view>
		</view>
	</view>

</template>

<script>
	import homeAlbum from './home-album/album.vue'
	import homeCategory from './home-category/category.vue'
	import homeNew from './home-new/new.vue'
	import homeRecommend from './home-recommend/recommend.vue'
	export default {
		components: {
			homeAlbum,
			homeCategory,
			homeNew,
			homeRecommend
		},
		data() {
			return {
				items: [{title: "推荐"},{title: "分类"},{title: "专辑"}],
				current: 0
			}
		},
		methods: {
			ClickSearch(){
				uni.navigateTo({
					url:"/pages/TabBarSearch/search"
				})
			},
			onClickItem(e) {
				this.current = e.currentIndex;
			}
		}
	}
</script>

<style lang="scss">
	.home_tab{
		.home_tab_title{
			position: relative;
			.title_inner{
				width: 60%;
				margin: 0 auto;
			}
			.icon-sousuo{
				position: absolute;
				top:50%;
				transform: translateY(-50%);
				right: 5%;
			}
		}
	}
</style>
